<?php
namespace Admin\Model;
use Think\Model;
class BannerModel extends Model {
	protected $tableName = 'banner';
	protected $_validate = [
		['title','require','标题不能空！'],
	]; 
	protected $_auto = [
		['title','strip_tags',3,'function'],
		//['src','strip_tags',3,'function'],
		['link','strip_tags',3,'function'],
		['time','changeTime',3,'callback'],
		['type','intval',3,'function'],
	];
	
	/**
	 * 删除
	 */
	public function del($id) {
		return $this->delete($id);
	}

	/**
	 * 处理时间
	 */
	protected function changeTime() {
		if(empty($_POST['time'])) {
			$time = time();
		} else {
			$time = strtotime(strip_tags($_POST['time']));
		}
		return $time;
	}
}

